<template>
  <div class="site_page">
    <nav-bar id="nav_bar" ref="nav_bar"/>
    <site_tab_bar ref="site_tab_bar"
                   id="site_tab_bar_box"
                   :handle_click_tab="handle_click_tab"
                   :is_tab_disable="is_tab_disable"/>
    <site_table ref="site_table" :site_code="current_site_code"/>
  </div>
</template>
<script>
import NavBar from "../components/nav-bar/nav_bar"
import GroupTabBar from "../components/nav-bar/group_tab_bar"
import Site_tab_bar from "@/components/nav-bar/site_tab_bar";
import Site_table from "@/components/site_table";

export default {
  name: "Site",
  components: {
    Site_table,
    Site_tab_bar,
    NavBar,
    GroupTabBar,
  },
  data() {
    return {
      table_data: [],
      current_site_code: 0, // 默认永远是0号：晨兴剧场
    }
  },
  methods: {
    get_default_active_tab() {
      return 0
    },
    handle_click_tab(tab, event) {
      // 点击tab之后修改当前的group_code
      // site_table会自己获取新数据

      this.current_group_code = parseInt(tab.index)
      this.$refs.site_table.set_site_code(this.current_site_code)
      this.$refs.site_table.reload_table_data()
    },
    is_tab_disable(index) {
      // 根据权限决定哪些tab是可以看的
      // 目前决定不设权限，都可以改
      return false
    }
  },
  mounted() {
    // 设置导航栏和tab的高亮
    this.$refs.site_tab_bar.set_default_active_tab(
        this.get_default_active_tab().toString())

    this.$refs.nav_bar.set_default_active_nav(
        this.$store.state.object_code_dir.type2object_code.场地)
  }

}
</script>
<style scoped>
#nav_bar {
  top: 0;
  position: fixed;
  width: 100%;
  opacity: 1;
  z-index: 90;
}
#site_tab_bar_box {
  width: 100%;
  top: 50px;
  padding-bottom: 50px;
  position: fixed;
  z-index: 100;
  background: #ffffff;
}
</style>